/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package AddManager;
import java.sql.*;
import DBManager.DBConnection;
/**
 *
 * @author maconcon
 */
public class AddManager {
    
     public boolean addManager(Manager newManager)
    {
        boolean result = false;
        
        try{
            //get connection
            DBConnection db = new DBConnection();
            Connection conn = db.getConnection();
            
          
            PreparedStatement pstmt =
                conn.prepareStatement("insert into manager(username,password,lastname,firstname,middle,type)"
                    + "values (?,?,?,?,?,?)");
            
            //append values for the parameters
            int i = 1;
            pstmt.setString(i++, newManager.getUsername());
            pstmt.setString(i++, newManager.getPassword());
              pstmt.setString(i++, newManager.getLastname());
            pstmt.setString(i++, newManager.getFirstname());
            pstmt.setString(i++, newManager.getMiddle());
                pstmt.setString(i++, newManager.getType());

            //execute SQL statement
            pstmt.executeUpdate();
            
            result = true;
        }
        catch(SQLException ex){ex.printStackTrace();}
        
        return result;
    }
}
